//
//  DHS2_PreOrder_PriceCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/10.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHS2_PreOrder_PriceCell.h"
#import "DHS2_PreOrder_Price_ItemCell.h"

@interface DHS2_PreOrder_PriceCell()<UITableViewDelegate, UITableViewDataSource>

@property (strong, nonatomic) NSArray *costArray;

@end

@implementation DHS2_PreOrder_PriceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerNib:[UINib nibWithNibName:@"DHS2_PreOrder_Price_ItemCell" bundle:nil] forCellReuseIdentifier:kDHS2_PreOrder_Price_ItemCell];
}

- (NSArray *)costArray{
    if (!_costArray) {
        _costArray = [NSArray array];
    }
    return _costArray;
}

- (void)updateCell:(NSDictionary *)dic{
    self.costArray = [dic objectForKey:@"cost"];
    [self.tableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.costArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 30;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DHS2_PreOrder_Price_ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:kDHS2_PreOrder_Price_ItemCell forIndexPath:indexPath];
    NSDictionary *dic = self.costArray[indexPath.row];
    cell.costLabel.text = [NSString stringWithFormat:@"%@：%@",[dic objectForKey:@"key"],[dic objectForKey:@"value"]];
    return cell;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
